package com.tca.cloud.standalone.person.biz.controller;

import com.tca.cloud.standalone.equipment.api.req.EquipmentReq;
import com.tca.cloud.standalone.equipment.api.resp.EquipmentResp;
import com.tca.cloud.standalone.equipment.api.service.EquipmentFeign;
import com.tca.cloud.standalone.person.api.req.PersonReq;
import com.tca.cloud.standalone.person.api.resp.PersonResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhouan
 * @Date 2021/7/29
 */
@RestController
@RequestMapping(value = "/person")
@Slf4j
public class PersonController {

    @Autowired
    private EquipmentFeign equipmentFeign;

    /**
     * 获取人员
     * @param personReq
     * @return
     */
    @PostMapping("/get")
    public PersonResp get(@Validated @RequestBody PersonReq personReq) {
        PersonResp personResp = new PersonResp();
        personResp.setId(personReq.getId());
        personResp.setAge(30);
        personResp.setName("Messi");

        EquipmentReq equipmentReq = new EquipmentReq();
        equipmentReq.setId(personReq.getId());
        EquipmentResp equipmentResp = equipmentFeign.get(equipmentReq);
        log.info("equipmentResp = {}", equipmentResp);
        return personResp;
    }
}
